package cn.bestick.thirteenKiller.ui;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * Created by bestick on 2016/1/17.
 */
public class JPanelKiller extends JPanel {

    private ImageIcon icon = null;
    private Image image = new ImageIcon("resources/shadow.png").getImage();
    public List<byte[]> list = null;
    public JLabel msg = new JLabel();
    public JPanel north;

    public JPanelKiller() {
        this.initCom();
        this.setLayout(null);
    }

    private void initCom() {
        this.north = new JPanel(new FlowLayout(0)) {
            public void paint(Graphics g) {
                super.paint(g);
                JPanelKiller.this.showCard(g);
            }
        };
        this.north.setBounds(10, 0, 300, 54);
        this.add(this.north);

        JPanel center = new JPanel(new FlowLayout(1));
        this.msg.setForeground(Color.RED);
        this.msg.setFont(new Font("黑体", 1, 24));
        center.setBounds(100, 56, 120, 120);
        center.add(this.msg);
        this.add(center);
    }

    public void showCard(Graphics g) {
        this.list = getList();
        if (this.list == null) {
            return;
        }
        int x = 0;
        for (int i = 0; i < this.list.size(); i++) {
            this.icon = new ImageIcon(this.list.get(i));
            g.drawImage(this.icon.getImage(), x, 20, null);
            x += 20;
        }
        g.drawImage(this.image, 254, 20, 1, 80, null);
    }

    public List<byte[]> getList() {
        return this.list;
    }

    public void setList(List<byte[]> list) {
        this.list = list;
    }
}
